export OBJ_DIR:=$(PWD)/obj
export USR_DIR:=$(PWD)/usr
export SRC_DIR:=$(PWD)/src
export INC_DIR:=$(PWD)/inc
export USR_FILE:=main.c
export SRC_FILE:=add.c sub.c mult.c div.c
export APP_NAME:=APP
export TARGET  :=$(PWD)/$(APP_NAME)

export OBJ_FILE:=$(patsubst %.c,$(OBJ_DIR)/%.o,$(SRC_FILE))
OBJ_FILE+=$(patsubst %.c,$(OBJ_DIR)/%.o,$(USR_FILE))

all:$(OBJ_FILE)
	gcc -o $(TARGET) $^

#$(OBJ_FILE):$(SRC_DIR)/*.c $(USR_DIR)/*.c
#	echo $@
#	$(MAKE) -C $(SRC_DIR)
#	$(MAKE) -C $(USR_DIR)

$(OBJ_DIR)/%.o:$(SRC_DIR)/%.c
	echo $@
	$(MAKE) -C $(SRC_DIR)

$(OBJ_DIR)/%.o:$(USR_DIR)/%.c
	echo $@
	$(MAKE) -C $(USR_DIR)

install:
	cp $(TARGET) /usr/bin

echo:
	echo $(OBJ_FILE)
clean:
	rm -f /usr/bin/$(APP_NAME)
	rm -f $(OBJ_DIR)/*  $(TARGET)
